home *** CD-ROM | disk | FTP | other *** search
/ The Netter Presenter: Ur…ion in Overactive Bladder / The Netter Presenter: Urinary System - Structure & Function in Overactive Bladder.iso / mac / UrinarySystem.app / Contents / Main.dxr / Internal_11_Import-Export Functions.ls < prev    next >
Encoding:
Text File  |  2005-01-18  |  12.6 KB  |  451 lines

  1. global gFile, gPersonalFilePath, gNoteData, glCurrentListData, gCurrentList, gPrefsFolder, gLibPrefsFolder, gFirstVisit, gPointerLoc, gPointerChannel, gLabelChannel, gLineChannel, gImageLibNum, gPathSymbol, gImageChannel, glSelectedLabels, glSelectedLines, gPFimportedData, gPFname, glPFnames, glPFListNames, glImageList, gLoadTime, gLibName, gListObject, gblack, ggreen, gred, gredx, filePath, gsize, gexportlistswitch, gexportppt, gprintlistimages
  2.  
  3. on ReadPrefs
  4.   gListObject = "PFList"
  5.   if not baFolderExists(gPrefsFolder) then
  6.     result = baCreateFolder(gPrefsFolder)
  7.     if the platform contains "Mac" then
  8.       gLoadTime = 5
  9.     else
  10.       gLoadTime = 14
  11.     end if
  12.     SaveSpeed()
  13.   end if
  14.   if not baFolderExists(gLibPrefsFolder) then
  15.     gFirstVisit = 1
  16.   else
  17.     gFirstVisit = 0
  18.   end if
  19.   glPFnames = []
  20.   repeat with i = 1 to the maxinteger
  21.     n = getNthFileNameInFolder(gLibPrefsFolder, i)
  22.     if n = EMPTY then
  23.       exit repeat
  24.       next repeat
  25.     end if
  26.     append(glPFnames, n)
  27.   end repeat
  28.   if glPFnames = [] then
  29.     gPFimportedData = "[" & QUOTE & "list1" & QUOTE & "]" & RETURN & "~list1" & RETURN & "~"
  30.     gPFname = "PersonalFile1"
  31.     glPFnames = ["PersonalFile1"]
  32.     gCurrentList = "list1"
  33.     value(gListObject).plImageData = [:]
  34.     glCurrentListData = []
  35.     value(gListObject).pCurrentImage = EMPTY
  36.     value(gListObject).plFoundImages = []
  37.     glPFListNames = ["list1"]
  38.     WritePersonalFileNoDialog()
  39.   else
  40.     gPFname = getAt(glPFnames, 1)
  41.     member("PFfile").text = gPFname
  42.     ReadPersonalFile()
  43.     gCurrentList = getAt(glPFListNames, 1)
  44.     member("PFlist").text = gCurrentList
  45.     repeat with lineNum = 1 to gPFimportedData.line.count
  46.       if gPFimportedData.line[lineNum].char[1] = "~" then
  47.         lineContent = gPFimportedData.line[lineNum]
  48.         if lineContent.char[2..lineContent.char.count] = gCurrentList then
  49.           platecount = 0
  50.           repeat while gPFimportedData.line[lineNum + platecount + 1].char[1] <> "~"
  51.             if gPFimportedData.line[lineNum + platecount + 1] = "[]" then
  52.               exit repeat
  53.             end if
  54.             platecount = platecount + 1
  55.           end repeat
  56.           value(gListObject).plFoundImages = []
  57.           glListImageNames = []
  58.           glCurrentListData = []
  59.           repeat with plateNum = lineNum + 1 to lineNum + platecount
  60.             plateData = value(gPFimportedData.line[plateNum])
  61.             if plateData = [:] then
  62.               exit repeat
  63.             end if
  64.             append(glCurrentListData, plateData)
  65.             append(glListImageNames, getPropAt(plateData, 1))
  66.           end repeat
  67.           repeat with nameNum = 1 to glListImageNames.count
  68.             imageName = getAt(glListImageNames, nameNum)
  69.             imageNumber = imageName.char[6..imageName.char.count]
  70.             if getOne(glImageList, imageNumber) <> 0 then
  71.               append(value(gListObject).plFoundImages, imageNumber)
  72.             end if
  73.           end repeat
  74.         end if
  75.       end if
  76.     end repeat
  77.   end if
  78.   gLoadTime = ReadSpeedFile(gPrefsFolder & "ILSSpeed")
  79.   gListObject = "WSearch"
  80.   member("PFfile").text = gPFname
  81.   member("PFlist").text = gCurrentList
  82. end
  83.  
  84. on SavePrefs
  85.   WriteReg(gPrefsFolder & "ILSReg", "1")
  86. end
  87.  
  88. on SaveSpeed
  89.   WriteSpeed(gPrefsFolder & "ILSSpeed", gLoadTime)
  90. end
  91.  
  92. on ReadRegFile WhichFile, WhichField
  93.   if objectp(gFile) then
  94.     gFile = 0
  95.   end if
  96.   gFile = new(xtra("fileio"))
  97.   openFile(gFile, WhichFile, 0)
  98.   theFile = readFile(gFile)
  99.   temp = theFile
  100.   repeat while 1
  101.     y = offset(numToChar(10), temp)
  102.     if y > 0 then
  103.       delete char y of temp
  104.       next repeat
  105.     end if
  106.     exit repeat
  107.   end repeat
  108.   theFile = temp
  109.   closeFile(gFile)
  110.   gFile = 0
  111.   return theFile
  112. end
  113.  
  114. on WriteReg WhichFile, thecontent
  115.   if objectp(gFile) then
  116.     gFile = 0
  117.   end if
  118.   gFile = new(xtra("fileio"))
  119.   openFile(gFile, WhichFile, 0)
  120.   delete(gFile)
  121.   createFile(gFile, WhichFile)
  122.   openFile(gFile, WhichFile, 0)
  123.   setFinderInfo(gFile, "TEXT ttxt")
  124.   writeString(gFile, thecontent)
  125.   closeFile(gFile)
  126.   gFile = 0
  127. end
  128.  
  129. on ReadSpeedFile WhichFile
  130.   if objectp(gFile) then
  131.     gFile = 0
  132.   end if
  133.   gFile = new(xtra("fileio"))
  134.   openFile(gFile, WhichFile, 0)
  135.   theFile = readFile(gFile)
  136.   temp = theFile
  137.   repeat while 1
  138.     y = offset(numToChar(10), temp)
  139.     if y > 0 then
  140.       delete char y of temp
  141.       next repeat
  142.     end if
  143.     exit repeat
  144.   end repeat
  145.   theFile = temp
  146.   closeFile(gFile)
  147.   gFile = 0
  148.   return value(theFile)
  149. end
  150.  
  151. on WriteSpeed WhichFile, thecontent
  152.   if objectp(gFile) then
  153.     gFile = 0
  154.   end if
  155.   gFile = new(xtra("fileio"))
  156.   openFile(gFile, WhichFile, 0)
  157.   delete(gFile)
  158.   createFile(gFile, WhichFile)
  159.   openFile(gFile, WhichFile, 0)
  160.   setFinderInfo(gFile, "TEXT ttxt")
  161.   writeString(gFile, string(thecontent))
  162.   closeFile(gFile)
  163.   gFile = 0
  164. end
  165.  
  166. on AppendTextFile thePath
  167.   if objectp(gFile) then
  168.     gFile = 0
  169.   end if
  170.   SaveString = " " & the text of field "input"
  171.   gFile = new(xtra("fileio"))
  172.   openFile(gFile, thePath, 0)
  173.   setPosition(gFile, getLength(gFile))
  174.   writeString(gFile, SaveString)
  175.   closeFile(gFile)
  176.   gFile = 0
  177. end
  178.  
  179. on ReadTextFile thePath
  180.   global content
  181.   if objectp(gFile) then
  182.     gFile = 0
  183.   end if
  184.   gFile = new(xtra("fileio"))
  185.   openFile(gFile, thePath, 0)
  186.   theFile = readFile(gFile)
  187.   temp = theFile
  188.   repeat while 1
  189.     y = offset(numToChar(10), temp)
  190.     if y > 0 then
  191.       delete char y of temp
  192.       next repeat
  193.     end if
  194.     exit repeat
  195.   end repeat
  196.   theFile = temp
  197.   content = theFile
  198.   closeFile(gFile)
  199.   gFile = 0
  200. end
  201.  
  202. on WriteTextFile thePath
  203.   if objectp(gFile) then
  204.     gFile = 0
  205.   end if
  206.   gFile = new(xtra("fileio"))
  207.   openFile(gFile, thePath, 0)
  208.   delete(gFile)
  209.   createFile(gFile, thePath)
  210.   openFile(gFile, thePath, 0)
  211.   setFinderInfo(gFile, "TEXT ttxt")
  212.   writeString(gFile, gNoteData)
  213.   closeFile(gFile)
  214.   gFile = 0
  215. end
  216.  
  217. on WriteTextFileWithDialog data
  218.   if objectp(gFile) then
  219.     gFile = 0
  220.   end if
  221.   gFile = new(xtra("fileio"))
  222.   thePath = displaySave(gFile, "Save Image Notes As:", value(gListObject).pCurrentImage & ".txt")
  223.   if thePath.char[thePath.char.count - 3..thePath.char.count] <> ".txt" then
  224.     put ".txt" after thePath
  225.   end if
  226.   openFile(gFile, thePath, 0)
  227.   delete(gFile)
  228.   createFile(gFile, thePath)
  229.   openFile(gFile, thePath, 0)
  230.   setFinderInfo(gFile, "TEXT ttxt")
  231.   writeString(gFile, data)
  232.   closeFile(gFile)
  233.   gFile = 0
  234. end
  235.  
  236. on ExportImage size
  237.   gsize = size
  238.   startTimer()
  239.   if objectp(gFile) then
  240.     gFile = 0
  241.   end if
  242.   gFile = new(xtra("fileio"))
  243.   if sprite(gImageChannel).member.type = #quickTimeMedia then
  244.     filePath = displaySave(gFile, "Save Animation To:", "Animation" & value(gListObject).pCurrentImage & ".mpg")
  245.   else
  246.     if size = "large" then
  247.       filePath = displaySave(gFile, "Save full size Image To:", "Figure" & value(gListObject).pCurrentImage & ".jpg")
  248.     else
  249.       filePath = displaySave(gFile, "Save half size Image To:", "Figure" & value(gListObject).pCurrentImage & ".jpg")
  250.     end if
  251.   end if
  252.   if filePath = EMPTY then
  253.     gFile = 0
  254.     exit
  255.   end if
  256.   if sprite(gImageChannel).member.type = #quickTimeMedia then
  257.     baCopyFile(the moviePath & "Images" & gPathSymbol & value(gListObject).pCurrentImage & ".mpg", filePath, "always")
  258.     if the result = 0 then
  259.       alert("The animation was exported successfully")
  260.     end if
  261.   else
  262.     PreviewModeON()
  263.     sprite(251).visible = 0
  264.     sprite(294).visible = 1
  265.     sprite(295).visible = 1
  266.     sprite(271).visible = 0
  267.     sprite(243).visible = 0
  268.     updateStage()
  269.     member("Screen Capture").picture = (the stage).picture
  270.     if the platform contains "Mac" then
  271.       image = new(xtra("DirectImage"), 241040691)
  272.     else
  273.       image = new(xtra("DirectImage"), 236558701)
  274.     end if
  275.     if filePath.char[filePath.char.count - 3..filePath.char.count] = ".TXT" then
  276.       delete filePath.char[filePath.char.count - 3..filePath.char.count]
  277.     end if
  278.     if filePath.char[filePath.char.count - 3..filePath.char.count] <> ".jpg" then
  279.       put ".jpg" after filePath
  280.     end if
  281.     imageLoadFromMember(image, member("Screen Capture", 1))
  282.     if size = "small" then
  283.       imageMinify(image)
  284.     end if
  285.     imageSaveToFile(image, "JPG:" & filePath, 100, 1, 1)
  286.     PreviewModeOFF()
  287.     sprite(294).visible = 0
  288.     sprite(295).visible = 0
  289.     sprite(251).visible = 1
  290.     sprite(271).visible = 1
  291.     sprite(243).visible = 1
  292.     updateStage()
  293.     loadTime = the timer / 60.0
  294.     gLoadTime = (gLoadTime + loadTime) / 2
  295.     forget(image)
  296.   end if
  297. end
  298.  
  299. on ExportListImages size
  300.   gsize = size
  301.   startTimer()
  302.   if glCurrentListData.count = 0 then
  303.     alert("There are no images to export.")
  304.     exit
  305.   end if
  306.   EstimateExportTime()
  307.   if objectp(gFile) then
  308.     gFile = 0
  309.   end if
  310.   gFile = new(xtra("fileio"))
  311.   if gexportppt = 1 then
  312.     gexportppt = 0
  313.     dtop = baSysFolder("desktop")
  314.     filePath = baGetFolder(dtop, "Select a folder for the new presentation.", 2, EMPTY, -2, 0)
  315.     if filePath = EMPTY then
  316.       gFile = 0
  317.       exit
  318.     end if
  319.     put glCurrentListData.count, glCurrentListData
  320.     baCopyFile(the moviePath & "PPT Programs" & gPathSymbol & "P" & string(glCurrentListData.count) & ".ppt", filePath & "Presentation.ppt", "always")
  321.     filePath = filePath & "ppt"
  322.   else
  323.     if size = "large" then
  324.       filePath = displaySave(gFile, "Save full size Images as:", gCurrentList)
  325.     else
  326.       filePath = displaySave(gFile, "Save half size Images as:", gCurrentList)
  327.     end if
  328.     if filePath = EMPTY then
  329.       gFile = 0
  330.       exit
  331.     end if
  332.   end if
  333.   if filePath.char[filePath.char.count - 3..filePath.char.count] = ".TXT" then
  334.     delete filePath.char[filePath.char.count - 3..filePath.char.count]
  335.   end if
  336.   sprite(gPointerChannel).loc = point(-200, 463)
  337.   sprite(293).member = "pointer button"
  338.   sprite(296).visible = 1
  339.   sprite(252).visible = 1
  340.   sprite(253).visible = 1
  341.   set the stageColor to the stageColor
  342.   gexportlistswitch = 1
  343.   go("export images")
  344. end
  345.  
  346. on printDoc
  347.   startTimer()
  348.   doc = new(xtra("PrintOMatic"))
  349.   setMargins(doc, rect(36, 36, 36, 36))
  350.   setLandscapeMode(doc, 1)
  351.   newPage(doc)
  352.   result = doJobSetup(doc)
  353.   if not result then
  354.     abort()
  355.   end if
  356.   sprite(251).visible = 0
  357.   sprite(294).visible = 1
  358.   sprite(295).visible = 1
  359.   sprite(271).visible = 0
  360.   sprite(243).visible = 0
  361.   PreviewModeON()
  362.   updateStage()
  363.   member("Screen Capture").picture = (the stage).picture
  364.   drawPicture(doc, member("Screen Capture"), rect(70, 0, 720, 540), 1)
  365.   if the optionDown then
  366.     printPreview(doc)
  367.   else
  368.     print(doc)
  369.   end if
  370.   doc = 0
  371.   sprite(294).visible = 0
  372.   sprite(295).visible = 0
  373.   sprite(251).visible = 1
  374.   sprite(271).visible = 1
  375.   sprite(243).visible = 1
  376.   PreviewModeOFF()
  377.   updateStage()
  378.   loadTime = the timer / 60.0
  379.   gLoadTime = ((gLoadTime * 4) + loadTime) / 5
  380. end
  381.  
  382. on PrintListImages
  383.   startTimer()
  384.   if glCurrentListData.count = 0 then
  385.     alert("There are no images to print.")
  386.     exit
  387.   end if
  388.   EstimateExportTime()
  389.   gprintlistimages = 1
  390.   go("export images")
  391. end
  392.  
  393. on RestoreImageToExport
  394.   LoadImageDefinition()
  395.   sprite(296).visible = 1
  396.   sprite(252).visible = 1
  397.   sprite(253).visible = 1
  398.   if gPointerLoc.locH < 200 then
  399.     sprite(gPointerChannel).member = "pointer button"
  400.     sprite(gPointerChannel).loc = point(-200, 463)
  401.     sprite(gPointerChannel).visible = 0
  402.   else
  403.     sprite(293).visible = 1
  404.     sprite(gPointerChannel).loc = gPointerLoc
  405.     sprite(gPointerChannel).member = "pointer"
  406.     sprite(gPointerChannel).visible = 1
  407.   end if
  408.   castLib("Plate").fileName = the moviePath & "Images" & gPathSymbol & "plate" & value(gListObject).pCurrentImage & ".cst"
  409.   glImageMap = value(member("Map", gImageLibNum).text)
  410.   sprite(gImageChannel + 1).loc = value(getAt(glImageMap, 1))
  411.   repeat with labelNum = gLabelChannel to gLabelChannel + 99
  412.     sprite(labelNum).visible = 0
  413.     if getOne(glSelectedLabels, labelNum) = 0 then
  414.       sprite(labelNum).loc = point(-400, 0)
  415.       next repeat
  416.     end if
  417.     sprite(labelNum).loc = value(getAt(glImageMap, labelNum - 41))
  418.     sprite(labelNum).visible = 1
  419.     if sprite(labelNum).member.type = #text then
  420.       sprite(labelNum).member.foreColor = 255
  421.     end if
  422.   end repeat
  423.   repeat with z = gLineChannel to gLineChannel + 99
  424.     if getOne(glSelectedLines, z) > 0 then
  425.       if sprite(z).member.type = #vectorShape then
  426.         sprite(z).visible = 1
  427.         case sprite(z).member.strokeColor of
  428.           gred:
  429.             sprite(z).member.strokeColor = gblack
  430.           gredx:
  431.             sprite(z).member.strokeColor = ggreen
  432.         end case
  433.       end if
  434.       next repeat
  435.     end if
  436.     sprite(z).visible = 0
  437.   end repeat
  438.   sprite(296).visible = 0
  439.   sprite(252).visible = 0
  440.   sprite(253).visible = 0
  441.   updateStage()
  442. end
  443.  
  444. on RestoreAnimationToExport
  445.   LoadImageDefinition()
  446.   castLib("Plate").fileName = the moviePath & "Images" & gPathSymbol & "plate" & value(gListObject).pCurrentImage & ".cst"
  447.   glImageMap = value(member("Map", gImageLibNum).text)
  448.   sprite(gImageChannel + 1).loc = value(getAt(glImageMap, 1))
  449.   updateStage()
  450. end
  451.